
using System.Web.UI.HtmlControls;
using System;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.Web.UI.WebControls;
using Microsoft.VisualBasic;
using System.Collections;
using System.Web.UI;
using System.Web;


using System.IO;
using System.Text;
//using com.ddsc.database;
using DDSC.OracleADO;
using com.ddsc.common;
using SMAS;
using System.Resources;

namespace smasb2b
{
	public class bulletin_pop : BasePage
	{
		
#region  Web Form 設計工具產生的程式碼
		
		//此為 Web Form 設計工具所需的呼叫。
		[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
		{
			
		}
		protected System.Web.UI.WebControls.Label lblPURCHASE_NO;
		protected ddscControlLibrary.InputBoxCtrl txtPURCHASE_NO;
		protected System.Web.UI.WebControls.Label lblPURCHASE_TEXT;
		protected ddscControlLibrary.InputBoxCtrl txtPURCHASE_TEXT;
		protected System.Web.UI.WebControls.Label lblPURCHASE_SPEC;
		protected ddscControlLibrary.InputBoxCtrl txtPURCHASE_SPEC;
		protected System.Web.UI.WebControls.Label lblEND_DATE;
		protected ddscControlLibrary.InputBoxCtrl txtEND_DATE;
		protected System.Web.UI.WebControls.Label lblPAY_TYPE;
		protected ddscControlLibrary.InputBoxCtrl txtPAY_TYPE;
		protected System.Web.UI.WebControls.Label lblDELIVERY_TYPE;
		protected ddscControlLibrary.InputBoxCtrl txtDELIVERY_TYPE;
		protected System.Web.UI.WebControls.Label lblDELIVERY_ADDRESS;
		protected ddscControlLibrary.InputBoxCtrl txtDELIVERY_ADDRESS;
		protected System.Web.UI.WebControls.Label lblSUPPLY_CONDITION;
		protected ddscControlLibrary.InputBoxCtrl txtSUPPLY_CONDITION;
		protected System.Web.UI.WebControls.Label lblCONTACT_NAME;
		protected ddscControlLibrary.InputBoxCtrl txtCONTACT_NAME;
		protected System.Web.UI.WebControls.Label lblCONTACT_ADDRESS;
		protected System.Web.UI.WebControls.Label lblCONTACT_TEL;
		protected ddscControlLibrary.InputBoxCtrl txtCONTACT_TEL;
		protected System.Web.UI.WebControls.Label lblCONTACT_EMAIL;
		protected ddscControlLibrary.InputBoxCtrl txtCONTACT_EMAIL;
		protected System.Web.UI.WebControls.Label lblREMARK_TEXT;
		protected ddscControlLibrary.InputBoxCtrl txtREMARK_TEXT;
		protected ddscControlLibrary.InputBoxCtrl txtHEAD;
		protected System.Web.UI.WebControls.Label lblMSG051;
		protected System.Web.UI.WebControls.Label lblMSG052;
		protected System.Web.UI.WebControls.Label lblPRINTPAGE;
		protected ddscControlLibrary.SubmitButtonCtrl btnAdd;
		protected System.Web.UI.WebControls.Label lblBULLETIN;
		protected System.Web.UI.WebControls.Label lblPURCHASE_IMAGE;
		protected System.Web.UI.HtmlControls.HtmlTableRow IMAGE_TR;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.HtmlControls.HtmlTableRow DOCUMENT_TR;
		
		
		//注意: 下列預留位置宣告是 Web Form 設計工具需要的項目。
		//請勿刪除或移動它。
		private System.Object designerPlaceholderDeclaration;
		
		private void Page_Init(System.Object sender, System.EventArgs e)
		{
			//CODEGEN: 此為 Web Form 設計工具所需的方法呼叫
			//請勿使用程式碼編輯器進行修改。
			InitializeComponent();
		}
		
#endregion
		public string g_szPURCHASE_NO;
		private void Page_Load(System.Object sender, System.EventArgs e)
		{
			//在這裡放置使用者程式碼以初始化網頁
			try
			{
				if (!Page.IsPostBack)
				{
					
					string PURCHASE_NO = Page.Request["purchase_no"];
					string version = Page.Request["version"];
					this.txtPURCHASE_NO.Text = Server.HtmlEncode(PURCHASE_NO);
                    ArrayList m_arrParam = new ArrayList();
                    dbAccess dba = new dbAccess();
					g_szPURCHASE_NO = PURCHASE_NO;

                    //Tony : 1.修改SQL語法使用參數，不組字串
					//string SelectCommand = string.Format("select PURCHASE_TEXT,PURCHASE_SPEC,END_DATE,PAY_TYPE,DELIVERY_TYPE,DELIVERY_ADDRESS,CONTACT_NAME,CONTACT_TEL,CONTACT_EMAIL,SUPPLY_CONDITION,REMARK_TEXT,DOCUMENT_TYPE from  B2B_PURCHASE_NOTICE WHERE PURCHASE_NO= \'{0}\' and version=\'{1}\' ", PURCHASE_NO, version);
                    string SelectCommand = "select PURCHASE_TEXT,PURCHASE_SPEC,END_DATE,PAY_TYPE,DELIVERY_TYPE,DELIVERY_ADDRESS,CONTACT_NAME,CONTACT_TEL,CONTACT_EMAIL,SUPPLY_CONDITION,REMARK_TEXT,DOCUMENT_TYPE from  B2B_PURCHASE_NOTICE WHERE PURCHASE_NO= :PURCHASE_NO and version=:version ";

                    //Tony : 2.設定動態參數物件
                    m_arrParam.Add(dba.GetOracleParam(":PURCHASE_NO", PURCHASE_NO));
                    m_arrParam.Add(dba.GetOracleParam(":version", version));

                    DataBase DataBase = new DataBase();
					DataSet ds = default(DataSet);

                    //Tony : 3.修改執行方法Overload
                    //ds = DataBase.Query_CLASS(SelectCommand, "B2B_PURCHASE_NOTICE");
					ds = DataBase.Query_CLASS(SelectCommand, "B2B_PURCHASE_NOTICE",m_arrParam);

					int Row = 0;
					if (!(ds == null) && ds.Tables["info"].Rows[0]["ReturnCode"] != "100" && ds.Tables["info"].Rows[0]["ReturnCode"] != "999")
					{
						
						Row = System.Convert.ToInt32(ds.Tables["B2B_PURCHASE_NOTICE"].Rows.Count - 1);
						this.txtHEAD.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["PURCHASE_TEXT"].ToString());
						this.txtPURCHASE_TEXT.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["PURCHASE_TEXT"].ToString());
						this.txtPURCHASE_SPEC.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["PURCHASE_SPEC"].ToString());
						string end_date_y = "";
						string end_date_m = "";
						string end_date_d = "";
						end_date_y = ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["END_DATE"].ToString().Substring(0, 4) + " 年 ";
						end_date_m = ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["END_DATE"].ToString().Substring(4, 2) + " 月 ";
						end_date_d = Strings.Right(System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["END_DATE"].ToString()), 2) + " 日";
						this.txtEND_DATE.Text = end_date_y + end_date_m + end_date_d;
						this.txtPAY_TYPE.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["PAY_TYPE"].ToString());
						this.txtDELIVERY_TYPE.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["DELIVERY_TYPE"].ToString());
						this.txtDELIVERY_ADDRESS.Text = ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["DELIVERY_ADDRESS"].ToString();
						this.txtCONTACT_NAME.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["CONTACT_NAME"].ToString());
						this.txtCONTACT_TEL.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["CONTACT_TEL"].ToString());
						this.txtCONTACT_EMAIL.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["CONTACT_EMAIL"].ToString());
						this.txtSUPPLY_CONDITION.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["SUPPLY_CONDITION"].ToString());
						this.txtREMARK_TEXT.Text = System.Convert.ToString(ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["REMARK_TEXT"].ToString());
						//Me.txtPAY_TYPE.Text = ds.Tables("B2B_PURCHASE_NOTICE").Rows(Row)("PAY_TYPE").ToString()
						if (ds.Tables["B2B_PURCHASE_NOTICE"].Rows[Row]["DOCUMENT_TYPE"].ToString() == "")
						{
							DOCUMENT_TR.Visible = false;
						}
					}
				}
			}
			catch (Exception ex)
			{
				showException(ex.Message);
			}
			
		}
		
		
	}
	
}
